/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package za.ac.cput.garethc.chpt2.intsort.impl;

import za.ac.cput.garethc.chpt2.intsort.IntSort;

/**
 *
 * @author Gareth
 */
public class IntSortImpl implements IntSort
{

    @Override
    public int[] bubbleSort(int [] nums) 
    {
        boolean sorted = false;
        
        for (int i = 1; i <= nums.length && !sorted; i++)
        {
            sorted = true;
            for (int j = 0; j < nums.length - i; j++)
            {
                if (nums[j] > nums[j+1])
                {
                    sorted = false;
                    int tmp = nums[j];
                    nums[j] = nums[j+1];
                    nums[j+1] = tmp;
                }
            }
        }
        
        return nums;
    }
    
}
